@extends('admin::layouts.master')
@section('content')
    @component('components.tabs',['title'=>'类目管理'])
        @slot('nav')
            <li class="nav-item"><a class="nav-link active" href="/article/category">类目列表</a></li>
            <li class="nav-item"><a class="nav-link" href="/article/category/create">添加类目</a></li>
        @endslot
        @slot('content')
                <table class="table table-striped table-borderless">
                    <thead>
                    <tr>
                        <th style="width: 10%;">编号</th>
                        <th style="width: 30%;">栏目名称</th>
                        <th style="width:20%;">创建时间</th>
                        <th style="width:20%;">修改时间</th>
                        <th class="actions" style="width:5%;"></th>
                    </tr>
                    </thead>
                    <tbody class="no-border-x">
                    @foreach($categories as $category)
                        <tr>
                            <td>{{$category['id']}}</td>
                            <td>{!!$category['_name']!!}</td>
                            <td class="text-success">{{$category['created_at']}}</td>
                            <td class="text-success">{{$category['updated_at']}}</td>
                            <td class="actions">
                                <div class="btn-group btn-space">
                                    <button class="btn btn-secondary" type="button" onclick="del({{$category['id']}},this)">删除</button>
                                    <form action="/article/category/{{$category['id']}}" method="post">
                                        @csrf
                                        @method("DELETE")
                                    </form>
                                    <a class="btn btn-secondary" type="button" href="/article/category/{{$category['id']}}/edit">编辑</a>
                                </div>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>

        @endslot
    @endcomponent
@endsection
@section('script')
    <script>
        function del(id,ct)
        {
            if(confirm("确认删除?")){
                $(ct).next('form').trigger('submit');
            }
        }
    </script>
@endsection
